import * as echarts from 'echarts';
import { EChartsOption } from 'echarts';
import 'echarts/theme/macarons';

import theme from '@/assets/js/theme';

export default function useEcharts(el: HTMLElement) {
  echarts.registerTheme('newTheme', theme);
  const ec = echarts.init(el, 'newTheme');

  const setOptions = (options: EChartsOption) => {
    ec.setOption(options);
  };
  return {
    ec,
    setOptions,
  };
}
